package client.core;

import java.io.PrintWriter;

public class Sender extends Thread {
	private PrintWriter writer;
	private String message;

	public Sender(PrintWriter writer) {
		this.writer = writer;
	}

	public void run() {
		while (!isInterrupted()) {
			if (message != null) {
				writer.println(message);
				message = null;
				writer.flush();
			}
		}
	}

	public synchronized void sendMessage(String message) {
		this.message = message;
	}
}
